Authors
¨	Makira (Antoine Missout), email: makira at users.sourceforge.net

Config. gui : Gordon Miller

Overview

	The MPEGEncoder pipe encodes a video sequence into MPEG1 or MPEG2 using the MJPEG Tools mpeg2enc and ppmtoy4v.

	The MPEG encoder, mpeg2enc, is distributed as source code only for legal reasons. It can be found inside the MPEGEncoder pipe bundle and compiled by hand with Project Builder, but for convenience, it will be compiled the first time the MPEGEncoder is used. This means that you need to have the Apple Developer Tools installed on your system in order for the MPEGEncoder to work.

	As the sequence is being fed to the MPEGEncoder, mpeg2enc buffers frames. Thus the pipe will look as though it is running really fast at first, and then it will slow down. This is normal behavior. At the end of the sequence, the buffer will slowly empty and it might take minutes between MediaPipe thinks the sequence is almost finished and before it actually is.

Usage
ppmtoy4m: just put [options] in MediaPipe.

usage:  ./ppmtoy4m [options] [ppm-file]

Reads RAW PPM image(s), and produces YUV4MPEG2 stream on stdout.
Converts computer graphics R'G'B' colorspace to digital video Y'CbCr,
 and performs chroma subsampling.

If 'ppm-file' is not specified, reads from stdin.

 options:  (defaults specified in [])

  -o n     frame offset (skip n input frames) [0]
  -n n     frame count (output n frames; 0 == all of them) [0]
  -F n:d   framerate [30000:1001 = NTSC]
  -A w:h   pixel aspect ratio [1:1]
  -I x     interlacing [p]
             p = none/progressive
             t = top-field-first
             b = bottom-field-first
  -L       treat PPM images as 2-field interleaved
  -r       repeat last input frame
  -S mode  chroma subsampling mode [420_jpeg]
            '420_jpeg' -> 4:2:0, JPEG/MPEG-1, interstitial siting
            '420_mpeg2' -> 4:2:0, MPEG-2, horizontal cositing
  -v n     verbosity (0,1,2) [1]

mpeg2enc : don't specify any output file.

--verbose|-v num
    Level of verbosity. 0 = quiet, 1 = normal 2 = verbose/debug
--format-f fmt
    Set pre-defined mux format fmt.
    [0 = Generic MPEG1, 1 = standard VCD, 2 = VCD,
     3 = Generic MPEG2, 4 = standard SVCD, 5 = user SVCD,
     6 = VCD Stills sequences, 7 = SVCD Stills sequences, 8 = DVD]
--aspect|-a num
    Set displayed image aspect ratio image (default: 2 = 4:3)
    [1 = 1:1, 2 = 4:3, 3 = 16:9, 4 = 2.21:1]
--frame-rate|-F num
    Set playback frame rate of encoded video
    (default: frame rate of input stream)
    0 = Display frame rate code table
Frame-rate codes:
 0 - UNDEFINED: illegal/reserved frame-rate ratio code
 1 - 24000.0/1001.0 (NTSC 3:2 pulldown converted FILM)
 2 - 24.0 (NATIVE FILM)
 3 - 25.0 (PAL/SECAM VIDEO / converted FILM)
 4 - 30000.0/1001.0 (NTSC VIDEO)
 5 - 30.0
 6 - 50.0 (PAL FIELD RATE)
 7 - 60000.0/1001.0 (NTSC FIELD RATE)
 8 - 60.0
--video-bitrate|-b num
    Set Bitrate of compress video in KBit/sec
    (default: 1152 for VCD, 2500 for SVCD, 3800 for DVD)
--nonvideo-birate|-B num
    Non-video data bitrate to assume for sequence splitting
    calculations (see also --sequence-length).
--quantisation|-q num
    Image data quantisation factor [1..31] (1 is best quality, no default)
    When quantisation is set variable bit-rate encoding is activated and
    the --bitrate value sets an *upper-bound* video data-rate
--output|-o pathname
    pathname of output file or fifo (REQUIRED!!!)
--vcd-still-size|-T size
    Size in KB of VCD stills
--interlace-mode|-I num
    Sets MPEG 2 motino estimation and encoding modes:
    0 = Progressive (non-interlaced)(Movies)
    1 = Interlaced source material (video)
--motion-search-radius|-r num
    Motion compensation search radius [0..32] (default 16)
--reduction-4x4|-4 num
    Reduction factor for 4x4 subsampled candidate motion estimates
    [1..4] [1 = max quality, 4 = max. speed] (default: 2)
--reduction-2x2|-2 num
    Reduction factor for 2x2 subsampled candidate motion estimates
    [1..4] [1 = max quality, 4 = max. speed] (default: 3)
--min-gop-size|-g num
    Minimum size Group-of-Pictures (default 12)
--max-gop-size|-G num
    Maximum size Group-of-Pictures (default 12)
    If min-gop is less than  max-gop, mpeg2enc attempts to place GOP
    boundaries to coincide with scene changes
--force-b-b-p|-P
    Preserve two B frames between I/P frames when placing GOP boundaries
--quantisation-reduction|-Q num
    Max. quantisation reduction for highly active blocks
    [0.0 .. 5] (default: 0.0)
--video-buffer|-V num
    Target decoders video buffer size in KB (default 46)
--video-norm|-n n|p|s
    Tag output to suit playback in specified video norm
    (n = NTSC, p = PAL, s = SECAM) (default: PAL)
--sequence-length|-S num
    Place a sequence boundary in the video stream so they occur every
    num Mbytes once the video is multiplexed with audio etc.
    N.b. --non-video-bitrate is used to the bitrate of the other
    data that will be multiplexed with this video stream
--3-2-pulldown|-p
    Generate header flags for 3-2 pull down of 24fps movie material
--intra_dc_prec|-D [8..10]
    Set number of bits precision for DC (base colour) of blocks in MPEG-2
--reduce-hf|-N
    Reduce high frequency resolution - useful as a mild noise reduction
--keep-hf|-h
    Maximise high-frequency resolution - useful for high quality sources
    and/or high bit-rates)
--sequence-header-every-gop|-s
    Include a sequence header every GOP if the selected format doesn't
    do so by default.
--no-dummy-svcd-SOF|-d
    Don't generate of dummy SVCD scan-data for the ISO CD image
    generator "vcdimager" to fill in.
--playback-field-order|-z b|t
    Force setting of playback field order to bottom or top first
--multi-thread|-M num
    Activate multi-threading to optimise through on a system with num CPU's
    [0..32], 0=no multithreading, (default: 1)
--correct-svcd-hds|-C
    Force SVCD horizontal_display_size to be 480 - standards say 540 or 720
    But many DVD/SVCD players screw up with these values.
--no-altscan-mpeg2
    Force MPEG2 *not* to use alternate block scanning.  This may allow some
    buggy players to play SVCD streams
--help|-?
    Print this lot out!

Troubleshooting
	
*	If it asks you to download the dev. tools, well do as it says!
*	Always restart with a fresh copy of the MediaPipe package if it says 'MPEGEncoder error: Could not compile mpeg2enc correctly'.
*	If you received the above error, please check if you are able to launch 'Project Builder' (/Developer/Applications/Project Builder). Also check: 

	-If this file exist: '/System/Library/PrivateFrameworks/JavaKit.framework/Versions/A/JavaKit', if not, use Pacifist (http://homepage.mac.com/csrstka/) to locate the file in the DeveloperKit installer. Copy it to the right place.
	-The console log. If you have an error like 'Builder can't open library: /System/Library/PrivateFrameworks/ToolSupport.framework/Versions/A/ToolSupport', your dev. tools are probably an old version, so download dev. tools again and restart from the beginning.
	-If these files exist in '/usr/include' : 'stdio.h', 'stdlib.h', 'pthread.h', 'machine/types.h'. If not either use Pacifist as above or reinstall the dev. tools.

*	If none of these get you up and running, then try starting with a fresh copy,  and try compiling mpeg2enc (ie using MPEGencoder),  and send me a copy of the console log of MediaPipe.

Related Links

¨
http://mjpeg.sourceforge.net

Discussion Forum:
http://sourceforge.net/forum/forum.php?thread_id=660143&forum_id=165128

Tutorials

Re-Encoding MPEG Video at a Lower Bitrate:
http://mediapipe.sourceforge.net/Articles/Article001.html

(S)VCD Transcoding using mediapipe:
http://www.ad-minds.com/tongue/svcd/

RNC’s Guide to SVCD on Mac:
http://homepage.mac.com/rnc/

MJPEG HowTo (contains revelent informatin about the options in mpeg2enc):
https://sourceforge.net/docman/display_doc.php?docid=3456&group_id=5776

Introduction to MPEG Video:
http://members.aol.com/symbandgrl/

Version changes
beside the numerous bug fixes...

v0.16.5 - 12/07/02
	-Forgot to make versions 0.16.3 and 0.16.4...
	-Updated to 0.8.2, then to 0.8.5
	-Added a config. window, then corrected some errors in it
	-Updated the mjpegtools to use klicman altivec optimizations, which are far better than mines... (see http://klicman.org/altivec/)

v0.16.2 - 25/05/02
	-Updated to Mediapipe 0.8.0
	-Added the ability to output to next pipe
	-Made a ReadMe

v0.16.1 - 13/05/02
	-Added some more altivec optimizations (SAD - another 7% speed increase)
	-Updated the MJPEG tools to version 1.6.0 final

v0.16 - 12/05/02
	-Added some altivec optimizations (DCT/iDCT - 7% speed increase)

v0.15
	-Inexistant

v0.14 - 23/02/02
	-Stabilized the configuration window
	-mpeg2enc compiles automatically the first time the pipe is used
	-The MJPEG tools are now hidden inside the pipe
	-Infos are logged to the console of MediaPipe

v0.13 - 16/03/02
	-Added a configuration window
	-Cleaned up the code
	-Correctly remember it's settings
	-Doesn't crash if bad arguments are given to mpeg2enc or ppmtoy4m

v0.12 - 14/03/02
	-Tries to remember it's settings

v0.11 - 18/02/02
	-The configuration is set via a file

v0.10 - 11/01/02
	-Uses mpeg2enc and ppmtoy4m from the MJPEG team

v0.01 - 09/01/02
	-First working version
	-Uses the mpeg encoder from MSSG

License

Copyright (c) 2002, Antoine Missout, Config. gui : Gordon Miller
All rights reserved.
Licensor: Antoine Missout

Redistribution and use in source and binary forms, without modification, are permitted provided that the following conditions are met:

*	Usage is non-commercial
*	Redistributions are free of charge
*	Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*	Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

For other types of distribution and/or usage, a special license must be obtained. Requests can be sent to makira at users.sourceforge.net.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

¨